#pragma once

#include  "iostream"
#include  "vector"
#include  "stack"
#include  "unordered_map"
#include   "queue"
#include "TypeDefin.h"

using namespace std;
////刚开始理解错了 这个速度写的不是特别慢 还是凑合吧 但是 原地反转估计费劲
ListNode *partition(ListNode *head, int x) {
    //维护两个一个比他小 一个大于等于她
    ListNode *first = new ListNode(-300);
    ListNode *sec = new ListNode(-300);
    auto secreal = sec;
    auto firstreal = first;
    while (head != nullptr) {
        auto t = new ListNode(head->val);
        /////
        if (head->val < x) {
            t->next = first->next;
            first->next = t;
            first = t;
        } else {
            t->next = sec->next;
            sec->next = t;
            sec = t;
        }
        head = head->next;
    }

    //寻找位置怎

    first->next = secreal->next;

    return firstreal->next;
}